/**
 * 添加或者修改页面
 */
var ExportSettingInfoDlg = {
    data: {
        id: "",
        exportName: "",
        paramClassName: "",
        exportMethodName: "",
        exportClassName: "",
        createUser: "",
        createTime: "",
        updateUser: "",
        updateTime: "",
        state: "",
        deleteFlag: ""
    }
};

layui.use(['form', 'admin', 'ax', 'laydate', 'upload'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    var paramClassNameTips;
    var exportMethodNameTips;
    var exportClassNameTips;

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var promise = validateExportSetting();
        promise.then(
            function (success) {
                var ajax = new $ax(Changein.ctxPath + "/exportSetting/addItem", function (data) {
                    Changein.success("添加成功！");
                    //传给上个页面，刷新table用
                    admin.putTempData('formOk', true);
                    //关掉对话框
                    admin.closeThisDialog();
                }, function (data) {
                    Changein.error("添加失败！" + data.responseJSON.message)
                });
                ajax.set(data.field);
                ajax.start();
            }
        )
        return false;
    });

    function validateExportSetting() {
        return new Promise(function (resolve, reject) {
            var exportCode = $("#exportCode").val();
            var ajax = new $ax(Changein.ctxPath + "/exportSetting/validateExportSetting", function (data) {
                if (data.code == 200) {
                    resolve(data);
                } else {
                    Changein.error("数据校验失败！" + data.message);
                    reject(data);
                }
            }, function (data) {
                Changein.error("数据校验失败！" + data.message);
                reject(data);
            });
            ajax.set({"exportCode": exportCode});
            ajax.start();
        })
    }

    $("#paramClassNameTips").mouseenter(function () {
        paramClassNameTips = layer.tips('指的是导出查询方法的请求参数包含类全路径的类名称，目前建议都统一使用java.util.Map作为参数类型！', '#paramClassNameTips', {
            tips: [1, '#555555'],
            area: ['500px', 'auto']
            // 上右下左四个方向，通过1-4进行方向设定
        });
    })
    $("#paramClassNameTips").mouseleave(function () {
        layer.close(paramClassNameTips);
    })
    $("#exportMethodNameTips").mouseenter(function () {
        exportMethodNameTips = layer.tips('指的是导出查询方法的方法名称，可以定义成默认的方法名称为getListByMap！', '#exportMethodNameTips', {
            tips: [1, '#555555'],
            area: ['500px', 'auto']
            // 上右下左四个方向，通过1-4进行方向设定
        });
    })
    $("#exportMethodNameTips").mouseleave(function () {
        layer.close(exportMethodNameTips);
    })
    $("#exportClassNameTips").mouseenter(function () {
        exportClassNameTips = layer.tips('指的是导出查询方法所在类半酣全路径的类名称，cn.changein.framework.modular.inventory.material.XXXX.service.impl.XXXXXImpl', '#exportClassNameTips', {
            tips: [1, '#555555'],
            area: ['500px', 'auto']
            // 上右下左四个方向，通过1-4进行方向设定
        });
    })
    $("#exportClassNameTips").mouseleave(function () {
        layer.close(exportClassNameTips);
    })
});